

<template>
    <div class="storeInfo">
        <div class="head">
            <el-form :model="form" class="headForm">
                <el-form-item>
                    <el-select clearable v-model="form.search_store_id" placeholder="全部门店">
                        <el-option v-for="item in storeList" :key="item.store_id" :label="item.title" :value="item.store_id"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item style="width:220px">
                    <el-date-picker v-model="timerange" value-format="yyyy-MM-dd" type="daterange" start-placeholder="存酒时间" end-placeholder="区间">

                    </el-date-picker>
                </el-form-item>
                <el-form-item label="" style="width:105px">
                    <el-input v-model="form.search" placeholder="会员姓名/手机号"></el-input>
                </el-form-item>

                <el-form-item>
                    <el-select clearable v-model="form.staff_id" placeholder="存酒经手人">
                        <el-option v-for="item in storeStaff" :key="item.user_id" :value="item.staff_id" :label="item.name"></el-option>
                    </el-select>
                </el-form-item>    
                <el-form-item>
                    <el-input placeholder="存酒名称" v-model="form.item_name"></el-input>
                </el-form-item>
                <el-button type="primary" icon="el-icon-search" @click="search">搜索</el-button>


            </el-form>
            
        </div>
        <!-- <p style="line-height:30px;padding-left:20px;margin-top:8px;color:#333" v-if="form.order_id == ''">最近{{total}}笔人工退款订单记录</p> -->
        <!-- table -->
        <div class="tabContainer_SI tabContainer">
            <el-table :data="tableData" stripe style="width: 100%;text-align:center" >
                <!--用户昵称	用户手机号	存酒名称	数量	过期剩余天数	存酒人	取酒人	存酒日期/取酒日期	门店名称	存/取备注	操作				 -->
                <el-table-column prop="user_name" label="用户昵称" fixed ></el-table-column>
                <el-table-column prop="mobile" label="用户手机号"> </el-table-column>
                <el-table-column prop="item_name" label="存酒名称" > </el-table-column>
                <el-table-column prop="" label="数量" >
                    <template slot-scope="scope">
                        <span>{{scope.row.item_num}}{{scope.row.unit}}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="expire_cn" label="过期剩余天数" ></el-table-column>
                <el-table-column prop="deposit_staff_name" label="存酒人"></el-table-column>
                <el-table-column prop="" label="取酒人">
                    <template slot-scope="scope">
                        <span v-if="scope.row.fetch_staff_name == ''">--</span>
                        <span v-else>{{scope.row.fetch_staff_name}}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="update_time" label="存酒日期/取酒日期">
                    <template slot-scope="scope">
                        <p>{{scope.row.create_time}}</p>
                        <p>{{scope.row.fetch_time}}</p>
                    </template>
                </el-table-column>
                <el-table-column prop="store_name" label="门店名称"></el-table-column>
                <el-table-column prop="update_time" label="存/取备注">
                    <template slot-scope="scope">
                        <p>存酒：{{scope.row.deposit_remarks}}</p>
                        <p>取酒：{{scope.row.fetch_remarks}}</p>
                    </template>
                </el-table-column>
                <el-table-column prop="" label="操作" v-if="limitList.length != 0">
                    <template slot-scope="scope">
                        <span v-for="(item,indexLimit) in limitList" :key="indexLimit" class="lightFont" @click="theClick(item.url,scope.row)">
                            <i>{{item.name}}</i>
                            <i v-if="indexLimit != limitList.length-1">&nbsp;|&nbsp;</i>
                        </span>
                    </template>          
                </el-table-column>
                <el-table-column v-else label="操作">/</el-table-column>

            </el-table>                       
        </div>
        <!-- 分页部分 -->
        <el-pagination
            background
            layout="total, prev, pager, next, jumper"
            @current-change="changePage"
            :page-size="size"
            :current-page.sync="pageNum"
            :hide-on-single-page=true
            :total="total">{{total}}
        </el-pagination>
        <el-dialog :title="editTitle" :visible.sync="add_edit_show" class="business">
            <el-form ref="form" :model="editForm" label-width="80px">
                <el-form-item label="有效期至">
                    <el-date-picker value-format="yyyy-MM-dd" placeholder="选择截至时间" type="date" v-model="editForm.renew_time">

                    </el-date-picker>
                    <!-- <el-input v-model="editForm.renew_time"></el-input> -->
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="add_edit_show = false">取 消</el-button>
                <el-button type="primary" @click="confrim">确 定</el-button>
            </div>
        </el-dialog>
    </div>
</template>

<style lang="scss">
.supplier{
        .el-dialog{
            .el-dialog__body{
                min-height: 300px;

            }
        } 
    }
  .tabContainer_SI{
      .el-table{
          .cell{
              text-align: center;
          }
      }
  }
</style>

<script>
import Vue from 'vue';
import { abc } from "../../../../js/abc.js";
import {potUrl} from '../../../../js/config_url.js'; 

export default {
    data () {
    return {
        tableData:[],
        total:50,
        size:20,
        form:{size:20,
            page:1
        },
        pageNum:1,
        limitList:[
            {name:"续存",url:"goOn"}
        ],
        editTitle:"",
        add_edit_show:false,
        editForm:{renew_time:''},
        storeStaff:[],//获取店长和员工得列表
        storeList:[],//获取门店列表
        timerange:[],

    }
  }, 
   mounted(){
      let that = this;
      that.getList();
      abc.getStore(that)
      abc.storeStaff(that)
  },
  methods:{
    search(){
        let that = this;
        console.log(that.timerange)
        if(that.timerange.length > 0){
            that.form.start_time  = that.timerange[0]
            that.form.end_time  = that.timerange[1]
        }
        that.getList()
    },
    changePage(val){
        var that = this;
        that.pageNum = val;
        that.form.page = val;
        that.getList()
    },
    getList(){
        let that = this;
        abc.get(that,potUrl.accesslist,that.form,(res)=>{
            that.tableData=res.data.list;
            that.total = res.data.total;
        })//列表
    },
    confrim(a){
        const that = this;
        that.add_edit_show = false;
        abc.post(that,potUrl.accessrenew,that.editForm,(res)=>{
            that.getList()
        })
    },
    theClick(a,b){
        const that = this;
        that.add_edit_show = true;
        let c = b.expire_time.split(' ')[0];
        that.editForm.renew_time = c
        that.editForm.access_id = b.access_id
    }
  }
}
</script>
